package org.budo.netty.servlet.server.handler.servlet;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;

/**
 * @author lmw
 */
public class BudoServletOutputStream extends ServletOutputStream {
    private ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

    public byte[] toByteArray() {
        return this.byteArrayOutputStream.toByteArray();
    }

    @Override
    public void write(int b) throws IOException {
        this.byteArrayOutputStream.write(b);
    }

    @Override
    public boolean isReady() {
        return true;
    }

    @Override
    public void setWriteListener(WriteListener writeListener) {
        throw new UnsupportedOperationException();
    }
}